#ifndef _WORKERTHREAD_H
#define _WORKERTHREAD_H

#include "01_Threadpool.hpp"
#include "06_Thread.hpp"
#include <stdlib.h>
#include <stdio.h>

class WorkerThread
:public Thread
{
public:
    WorkerThread(ThreadPool& threadpool)
        :_threadpool(threadpool){}
    ~WorkerThread() = default;

    void run() override
    {
        //// 1: 直接循环卡死了，出不来
        //while(1){   
        //    _threadpool.doTask();
        //}
        
        //2: 可以正常执行，但是AI讲这个会使线程频繁创建与销毁，我觉得没什么问题啊
        _threadpool.doTask();
        
        ////3:可以正常执行，但雀食没必要这么写啊
        //while(_threadpool.get_is_exit() == false){
        //    _threadpool.doTask();
        //}
        
    }
private:
    ThreadPool& _threadpool;
};

#endif

